Skip to main content
tip

Although the step-by-step instructions described here are simple to follow, this steps are available as an automated script.

To use the automated script execute the following command in your server terminal, select Node Update from the Tools menu option and follow the instructions:

curl -sS https://get.fleek.network | bash
warning

To prevent any negative impact on the node's reputation, it's advisable to wait until the end of the Epoch (~24h) before shutting down the node when opting out. The same applies to nodes that have opted-in but are currently offline.

To learn more, read the Lightning-CLI section for command opt.

tip

Shutting down a Node after an Epoch can be tedious, given the remaining time an Epoch can take to end. Doing it prematurely, will cause reputation penalties, e.g. shutting down before the participation state change to offline. Therefore, a shutdown utility is available in the Tools menu option of get.fleek.network.

To access it, execute the command:

curl https://get.fleek.network | bash

Switch to the installation user

Switch to the username you've used throughout the installation process.

su <USERNAME>

For example, if you used the username lgtn it'll look like the following command:

su lgtn

Change directory to the source code

If you have installed it via the recommended process or instructions, then the default location where the source code is stored is ~/fleek-network/lightning.

cd ~/fleek-network/lightning
tip

Notice that we use ~, which refers to $HOME. You must use the username used for the installation process. For example, on Ubuntu if you use the username lgtn, the pathname for $HOME is /home/lgtn.

Checkout to branch

Make sure that you are checked in to the correct branch. For the current testnet phase that'd be testnet-alpha-1. If you use any other branch name, your node will not function correctly. Use the branch name testnet-alpha-1.

git checkout testnet-alpha-1
tip

We try to update our documentation promptly but sometimes are a bit behind on any changes we might make in real-time. If you find any typos, such as the wrong branch name, help us by letting us know! Find us in Fleek Network section of our Discord.

Pull the latest changes

Before make sure that you stash or clear any changes you may have in the working directory, as otherwise, git will let you know about local changes–if you'd like to learn more about it read the git stash document.

A quick way to clean is to stash the changes, for example:

git stash 

To pull the latest changes use the git pull command, as follows:

git pull origin testnet-alpha-1

Alternatively, to have to stash and pull, you can reset the repository to the origin.

git fetch origin testnet-alpha-1
git reset --hard origin/testnet-alpha-1
git clean -f
tip

We are using the branch named testnet-alpha-1, which is specific to the early testnet launch. Change to the correct branch name according to needs. For example, in the future the mainnet version will go on branch name main.

Build binary from the source

To build the binary from the source code, we execute the cargo build command:

cargo +stable install --locked --path core/cli --features services
tip

The command uses the stable rust toolchain, if the command fails you have to install it, run the following commands:

rustup toolchain install stable

Optionally, set stable as default toolchain as follows:

 rustup default stable

Start by removing the existing one:

sudo rm -f "/usr/local/bin/lgtn"

Create a new symlink that links the new build binary to /usr/local/bin/lgtn, as follows:

sudo ln -s ~/fleek-network/lightning/target/release/lightning-node /usr/local/bin/lgtn

Set user path in config.toml

You should be following the create a user recommendation. For our example, we have the username lgtn.

tip

If you have chosen a different username, replace lgtn by the correct username you have selected.

In the config.toml you'll find some and more of the following:

[BLANK]

[application]
db_path = "~/.lightning/data/app_db"

[consensus]
store_path = "~/.lightning/data/narwhal_store"

[fsstore]
root = "~/.lightning/blockstore"

[resolver]
store_path = "~/.lightning/data/resolver_store"

[signer]
consensus_key_path = "~/.lightning/keystore/consensus.pem"
node_key_path = "~/.lightning/keystore/node.pem"

Find and replace all instances of ~ in the config file /home/lgtn/.lightning/config.toml. Here's an example using sed:

sed -i "s|~/.lightning|/home/lgtn/.lightning|g" "/home/lgtn/.lightning/config.toml"
caution

The config.toml example below is a shorter version of what you'll encounter, yours might look different. We do this to keep the guide simple to read. Do not copy and replace with the version demonstrated here.

Once changed, all the instances of ~/ should be replaced by your user path e.g. /home/lgtn/. For our example, the output would look like the following:

[BLANK]

[application]
db_path = "/home/lgtn/.lightning/data/app_db"

[consensus]
store_path = "/home/lgtn/.lightning/data/narwhal_store"

[fsstore]
root = "/home/lgtn/.lightning/blockstore"

[resolver]
store_path = "/home/lgtn/.lightning/data/resolver_store"

[signer]
consensus_key_path = "/home/lgtn/.lightning/keystore/consensus.pem"
node_key_path = "/home/lgtn/.lightning/keystore/node.pem"

Update the systemd service unit

Open and edit the /etc/systemd/system/lightning.service file.

  1. Replace <YOUR-USERNAME> with the username. For example, in the documentation we use the username lgtn.

  2. Make sure that the ExecStart is set correctly

[Unit]
Description=Fleek Network Node lightning service

[Service]
Type=simple
MemoryHigh=32G
RestartSec=15s
Restart=always
ExecStart=lgtn -c /home/<YOUR-USERNAME>/.lightning/config.toml -vv run
StandardOutput=append:/var/log/lightning/output.log
StandardError=append:/var/log/lightning/diagnostic.log
Environment=TMPDIR=/var/tmp

[Install]
WantedBy=multi-user.target
note

The flag -c in the lightning.service ExecStart, is to provide the toml configuration file path e.g. defaults to ~/.lightning/config.toml. This is to avoid the path being determined dynamically (given path base ~ or $HOME), as users might control the systemctl service as a user or sudoer. For example, a sudoer would have the configuration set to /root/.lightning/config.toml or /home/username/.lightning/config.toml depending on using sudo which might cause some confusion to some users.

When complete make sure the file is saved. Followed by a systemctl daemon reload:

sudo systemctl daemon-reload

Clear the data

rm -rf ~/.lightning/data

Depending on how you control the system, this might need sudo.

sudo rm -rf ~/.lightning/data

Update the config.toml

Remove the ~/.lightning/config.toml.

rm ~/.lightning/config.toml

Create a new config.toml

lgtn print-config --default > ~/.lightning/config.toml

Update the config.toml with user home path

In the /home/<USERNAME>/.lightning/config.toml you'll find some and more of the following:

[BLANK]

[application]
db_path = "~/.lightning/data/app_db"

[consensus]
store_path = "~/.lightning/data/narwhal_store"

[fsstore]
root = "~/.lightning/blockstore"

[resolver]
store_path = "~/.lightning/data/resolver_store"

[signer]
consensus_key_path = "~/.lightning/keystore/consensus.pem"
node_key_path = "~/.lightning/keystore/node.pem"
tip

The configuration properties and values presented above are a shorter version of what you'll find on your configuration.toml. We keep it short to make it easier to follow, do not copy and paste.

Find and replace all instances of ~ in the config file /home/<USERNAME>/.lightning/config.toml.

Here's an example of how to do it using sed:

sed -i "s|~/.lightning|/home/<USERNAME>/.lightning|g" "/home/<USERNAME>/.lightning/config.toml"
tip

Replace the <USERNAME> with your username. For example, if you have followed the recommendation to create a user it would look like /home/lgtn/.lightning/config.toml for the username lgtn.

For example, if your username is lgtn that'd look like this:

sed -i "s|~/.lightning|/home/lgtn/.lightning|g" "/home/lgtn/.lightning/config.toml"

Once modified, you can run a cat to see the content of the files to confirm it has been updated.

cat /home/lgtn/.lightning/config.toml

For our example where we opted in for the username lgtn that would look like:

[BLANK]

[application]
db_path = "~/.lightning/data/app_db"

[consensus]
store_path = "~/.lightning/data/narwhal_store"

[fsstore]
root = "~/.lightning/blockstore"

[resolver]
store_path = "~/.lightning/data/resolver_store"

[signer]
consensus_key_path = "~/.lightning/keystore/consensus.pem"
node_key_path = "~/.lightning/keystore/node.pem"
Warning

Bear in mind that we are keeping the content of the file short to make it easier to read and follow. The content of your configuration file should look slightly different, amongst these it should contain other properties and values. You should not copy and replace the content of your files with the ones presented here.

Restart the service

Once the cargo build process is completed, you have to restart the service. We're assuming you are using non-root user as recommended, you won't use sudo to start the service. The command will look as follows:

sudo systemctl restart lightning
tip

If you have installed the Fleek Network lightning manually, the installation instructions recommended setting up a systemd service for the Fleek Network process. If you haven't, you're advised to check the instructions provided.

Health checkup

Do a quick health check by running:

curl -w "\p" localhost:4230/health

If successful, you should get the response running and staked, as follows:

running and staked
Helder Oliveira
Helder OliveiraSoftware Developer + DXGot questions? Find us on discord!